package com.jimmy.medical.base.impl;

import com.jimmy.medical.base.JpaSpecificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.NoRepositoryBean;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.io.Serializable;
import java.util.List;

@NoRepositoryBean
public class JpaSpecificationServiceImpl<JpaRep extends JpaSpecificationExecutor<T>, Rep extends PagingAndSortingRepository<T, ID>, T, ID extends Number>
        extends PagingAndSortingServiceImpl<Rep, T, ID>
        implements JpaSpecificationService<JpaRep, Rep, T, ID> {

    @Autowired
    protected JpaRep jpaRep;

    @Override
    public T findOne(Specification<T> var1) {
        return jpaRep.findOne(var1);
    }

    @Override
    public List<T> findAll(Specification<T> var1) {
        return jpaRep.findAll(var1);
    }

    @Override
    public Page<T> findAll(Specification<T> var1, Pageable var2) {
        return jpaRep.findAll(var1, var2);
    }

    @Override
    public List<T> findAll(Specification<T> var1, Sort var2) {
        return jpaRep.findAll(var1);
    }

    @Override
    public long count(Specification<T> var1) {
        return jpaRep.count(var1);
    }
}
